/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dal;

import Util.HibernateUtil2;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import pojo.Orders;

/**
 *
 * @author Sy Dai
 */
public class order {

    public order() {
    }

    public static boolean add_order(Orders order) {
        Session session = HibernateUtil2.getSessionFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
            session.save(order);
            transaction.commit();
        } catch (HibernateException ex) {
            //Ghi loi vao file Log su dung Log4J
            transaction.rollback();
            throw new HibernateException(ex.toString());
        } finally {
            session.close();
        }
        return true;
    }
}
